<template>
  <ul class="todo-list">
    <!-- completed: 完成的类名 -->
    <li
      :class="{completed: obj.isDone}"
      v-for="obj in arr"
      :key="obj.id"
    >
      <div class="view">
        <input
          class="toggle"
          type="checkbox"
          v-model="obj.isDone"
        />
        <label>{{ obj.name }}</label>
        <button
          class="destroy"
          @click="delTask(obj.id)"
        ></button>
        <!-- 删除按钮绑定点击事件 -->
      </div>
    </li>
  </ul>

</template>

<script>
export default {
  props: {
    arr: Array
  },
  methods: {
    // 删除任务
    delTask(id) {
      this.$emit('delTask', id)
    }
  }
}
</script>